package com.ruoyi.common.pms.dao;

import com.ruoyi.common.pms.entity.YytPmsSpuAttrValue;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * spu属性值 Mapper 接口
 * </p>
 *
 * @author huangshun
 * @since 2021-12-16
 */
@Repository
public interface YytPmsSpuAttrValueMapper extends BaseMapper<YytPmsSpuAttrValue> {

    /**
     * 根据spuId获取规格参数列表
     */
    @Select("select * from yyt_pms_spu_attr_value where spu_id = #{spuId}")
    @Results({
            @Result(property = "attrId", column = "attr_id"),
            @Result(property = "groupId", column = "attr_id",
                    one = @One(select = "com.ruoyi.common.business.dao.YytAttrAttrgroupRelationMapper.getGroupId"))
    })
    List<YytPmsSpuAttrValue> listBySpuId(String spuId);
}
